package common

import (
	"fmt"
	"net"
)

//要收集的日志的配置项结构体
type CollectEntry struct {
	Path  string `ini:"path"` //日志文件存放的路径，去哪个路径读取日志文件
	Topic string `ini:"topic"` //日志文件发往kafka中的那个topic
}

const(
	CanNotGetIP = "get.ip.failed!"
)

func GetOutboundIP() (ip string,err error) {
	conn, err := net.Dial("udp", "8.8.8.8:80")
	if err != nil {
		return CanNotGetIP,err
	}
	defer conn.Close()

	localAddr := conn.LocalAddr().(*net.UDPAddr)
	fmt.Println(localAddr.String())
	return localAddr.IP.String(),nil
	//return strings.Split(localAddr.IP.String(),":")[0],nil
}